home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
vol_300
/
311_01
/
db.doc
< prev
next >
Wrap
Text File
|
1990-04-21
|
48KB
|
1,459 lines
###### ###### ###### ####### #####
# # # # # # # # # #
# # # # # # # # #
# # ###### # # # # #
# # # # ### # # # # #
# # # # ### # # # # # #
###### ###### ### ###### ####### #####
# # # #####
# # ## # #
# # # # #
# # # #####
# # # ### #
# # # ### # #
# ##### ### #####
(c) 1987, 1990
Ken Harris
901 E. Hampton
Milwaukee, WI 53217
(414) 962-1961
harris@cvax.cs.uwm.edu
/****************************************************************************/
/* */
/* This software is made available on an AS-IS basis. Unrestricted */
/* use is granted provided that the copyright notice remains intact. */
/* The author makes no warranties expressed or implied; however, any */
/* feedback is welcome. */
/* */
/****************************************************************************/
V1.2 Release Notes:
---- ------- -----
(1) The DB_READ_LAST and DB_READ_PREV routines have been added
to allow backwards traversal. The routines work for all three
file types. DB_DELETE should not be used with these routines.
The delete routine sets the current record pointer so that a
subsequent DB_READ_NEXT will work correctly. A DB_READ_PREV
loop with DB_DELETES will result in skipped records.
(2) A number of bugs in the file create routine have been fixed.
(3) A file corruption bug in the Index delete routine has been
fixed.
(4) The distribution has been divided into three separately
compiled files.
(5) Large memory model now works correctly.
(6) A lot of "warning" type problems have been cleaned up.
(7) Just before releasing V1.2 Microsoft C V5.0 rolled in
the door so I was able to fix a couple of problems.
There are still some warning messages while compiling
db_main.c. This is the result of ",..." type declarations
used to prevent type checking of the user_data argument.
User programs don't have to type cast user_data to char*
to avoid warnings.
(8) I have avoided the temptation of using too many of the
ANSI C extensions for those folks with old compilers.
Also I'd rather not fill the code with a zillion IFDEF's.
V1.3 Release Notes:
---- ------- -----
(1) A variable type file has been added. It is a sequential file
with variable length records.
(2) A simple object dictionary manager has been added. It works
well for a small data base of non-homogeneous objects, for
example setup data records.
(3) The file descriptor pointer is now called DATA_FILE instead of
DATA_SET. DATA_SET is still defined so that V1.2 programs
will compile.
(4) The db_create routine arguments have changed. An option
string is now passed instead of a df_file_hdr pointer. This
is much cleaner. It will require changing any V1.2 programs
before they will work.
(5) A number of routines now take an optional final record size
argument. This is only required for VAR type files. It may
be ignored for other file types.
(6) Existing V1.2 data files should work with V1.3 routines.
The first time the file is openned and updated the file
version will be changed from 1.2 to 1.3.
(7) Compiler conditionals have been added to DB_MAIN.C to
bracket references to file-type specific routines. This
makes it possible to build a library with support for
only file types you need. The lexical variables are
SEQ, RAN, IDX, VAR and ALL. So if SEQ is defined, then
sequential file support is included, etc. Note that
DB_DICT uses VAR files. If an attempt is made to access
an unsupported file-type an error will occur.
Only the references to routines are IFDEFed. If you build
a subset library you will probably get warning messages
about some unreferenced variables. It's ok.
(8) Compiler conditionals are used to bracket compiler specific
code. The current conditionals are:
MSC - Microsoft C
TURBO - Turbo C
SYSV - Unix Sys V
In addition ANSI can be defined to use ANSI style function
prototypes. You will probably want to edit #defines for
your compiler and ANSI at the beginning of db.h.
(9) A header file, dblib.h, has been added for building the
library. It is not needed for application programs. It
contains compiler specific includes and defines.
V1.3 Release Notes (cont):
---- ------- -----
(10) The header file contains references to DB_LINK routines.
These are routines for linking records between files.
They have not been included in the distribution.
(11) The routines memedt and stredt are no longer used by the
db routines and have been removed from the distribution.
(12) The *test.c files are intended to provide a minimal test
of the routines. If the the tests run to compeletion
without crashing or generating a DB-ERROR then there is
a good chance that you're in business. The tests are
not necessarily good examples of using the routines.
(13) The routines have been built and tested on several
different machines. Most of the development for v1.3
was done under Ultrix on a VAXstation-2000 with gcc.
It has also been sucessfully built using MSC 5.1 and
Turbo C 2.0 under MSDOS and cc under Unix on a 3B1.
If your compiler is not one of these you should still
be able to build the routines without too much trouble.
Search through the code for MSC 's and add an
appropriate case for your compiler.
(14) Note that although this code works fine on Unix systems,
it is still single user. There is no support for record
locking or file sharing.
+----------+ ------------------- +----------+
| db_Intro | - DB Introduction - | db_Intro |
+----------+ ------------------- +----------+
o Description
This document describes the DB package for maintaining
data files. The package consists of a library of file handling
routines which may be linked with user programs.
The following four file organizations are supported:
(1) Sequential - This file is a sequential stream of fixed
length records.
(2) Index - Data records are stored in an ISAM type
organization.
(3) Random - Data records are stored using a hashed method.
(4) Variable - A sequential stream of variable length
records.
The following operations are supported:
db_read_last - Read Last Record
db_read_prev - Read Prev Record
db_add - Add a New Record a File
db_close - Close an Open Data Set
db_create - Create a New Data Set
db_delete - Delete the Current Record
db_dict_add - Dict Add Object
db_dict_close - Dict Close
db_dict_delete - Dict Object Delete
db_dict_delete_all - Dict Delete A